﻿namespace GSC.WebControls
{
    using System;
    using System.Collections.Generic;
    using System.Web.UI.Design;
    using System.Web.UI.Design.WebControls;
    using System.ComponentModel;
    using System.Web.UI;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.IO;
    using System.ComponentModel.Design;
    using System.Web.UI.HtmlControls;
    /// <summary>
    /// 管理后台页面模板控件设计器。
    /// </summary>
    /// <remarks>管理后台页面模板控件设计器。</remarks>
    internal class BackgroundControlDesigner : CompositeControlDesigner
    {
        protected override void PostFilterProperties(System.Collections.IDictionary properties)
        {
            base.PostFilterProperties(properties);
            if (string.IsNullOrEmpty(_Master.DefaultMenuAscx))
            {
                if (!properties.Contains("CenterLeftMenuTitles"))
                {
                    PropertyDescriptor pdItems = TypeDescriptor.CreateProperty(
                        typeof(BackgroundCenterLeftMenuControlDesigner),
                        "CenterLeftMenuTitles",
                        typeof(BackgroundCenterLeftMenuTitleControlCollection),
                        new Attribute[] { new DesignOnlyAttribute(true) });
                    properties.Add("CenterLeftMenuTitles", pdItems);
                }
            }
            else
            {
                if (properties.Contains("CenterLeftMenuTitles"))
                    properties.Remove("CenterLeftMenuTitles");
            }
        }
        /// <summary>
        /// 获取一个值，该值指示是否可以在设计时环境中调整控件的大小。 （继承自 ControlDesigner。）
        /// </summary>
        /// <remarks>获取一个值，该值指示是否可以在设计时环境中调整控件的大小。 （继承自 ControlDesigner。）</remarks>
        /// <value>bool</value>
        public override bool AllowResize
        {
            get
            {
                return false;
            }
        }
        /// <summary>
        /// 控件对象。
        /// </summary>
        /// <remarks>控件对象。</remarks>
        private BackgroundControl _Master;
        /// <summary>
        /// 获取模板组的集合，每个模板组包含一个或多个模板定义。 （继承自 ControlDesigner。）
        /// </summary>
        /// <remarks>获取模板组的集合，每个模板组包含一个或多个模板定义。 （继承自 ControlDesigner。）</remarks>
        /// <value>System.Web.UI.Design.TemplateGroupCollection</value>
        public override TemplateGroupCollection TemplateGroups
        {
            get
            {
                TemplateGroupCollection collection = new TemplateGroupCollection();
                TemplateGroup group;
                TemplateDefinition template;
                BackgroundControl control;
                control = (BackgroundControl)Component;
                //
                group = new TemplateGroup("BackgroundHeadControl");
                template = new TemplateDefinition(this, "HeadLogoTemplate", control, "HeadLogoTemplate", false);
                group.AddTemplateDefinition(template);
                template = new TemplateDefinition(this, "HeadLogoutTemplate", control, "HeadLogoutTemplate", false);
                group.AddTemplateDefinition(template);
                collection.Add(group);
                //
                group = new TemplateGroup("BackgroundCenterHeadControl");
                template = new TemplateDefinition(this, "CenterHeadLeftCellTemplate", control, "CenterHeadLeftCellTemplate", false);
                group.AddTemplateDefinition(template);
                template = new TemplateDefinition(this, "CenterHeadCenterCellTemplate", control, "CenterHeadCenterCellTemplate", false);
                group.AddTemplateDefinition(template);
                collection.Add(group);
                group = new TemplateGroup("BackgroundCopyrightControl");
                template = new TemplateDefinition(this, "CopyrightContentTemplate", control, "CopyrightContentTemplate", false);
                group.AddTemplateDefinition(template);
                collection.Add(group);
                return collection;
            }
        }

        /// <summary>
        /// 创建该 CompositeControl 控件的子控件。
        /// </summary>
        /// <remarks>创建该 CompositeControl 控件的子控件。</remarks>
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            foreach (BackgroundHeadControlItem item in this._Master.HeadItems)
            {
                ((ICompositeControlDesignerAccessor)item).RecreateChildControls();
            }
            foreach (BackgroundCenterLeftMenuTitleControl item in this._Master.CenterLeftMenuTitles)
            {
                foreach (BackgroundCenterLeftMenuButtonControl citem in item.Buttons)
                {
                    ((ICompositeControlDesignerAccessor)citem).RecreateChildControls();
                }
                ((ICompositeControlDesignerAccessor)item).RecreateChildControls();
            }
        }
        /// <summary>
        /// 初始化控件设计器并加载指定的组件。 （继承自 ControlDesigner。）
        /// </summary>
        /// <remarks>初始化控件设计器并加载指定的组件。 （继承自 ControlDesigner。）</remarks>
        /// <param name="Component"></param>
        public override void Initialize(IComponent Component)
        {
            base.Initialize(Component);
            if (this._Master == null)
            {
                this._Master = (BackgroundControl)Component;
            }
            SetViewFlags(ViewFlags.DesignTimeHtmlRequiresLoadComplete, true);
            this.SetViewFlags(ViewFlags.TemplateEditing, true);
        }
        /// <summary>
        /// 检索用于在设计时显示关联数据源控件的 HTML 标记。
        /// </summary>
        /// <remarks>检索用于在设计时显示关联数据源控件的 HTML 标记。</remarks>
        /// <returns>string</returns>
        public override string GetDesignTimeHtml()
        {
            try
            {
                //
                this.CreateChildControls();
                //
                string l = System.Threading.Thread.CurrentThread.CurrentCulture.Name.Replace("-", "_");
                Panel panel = new Panel();
                panel.Style["height"] = "auto";
                panel.Style["text-align"] = "left";
                panel.Style["vertical-align"] = "top";
                panel.Style["background-position"] = "left top";
                panel.Style["background-repeat"] = "repeat-x";
                if (string.IsNullOrEmpty(this._Master.BackImageUrl))
                    panel.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundControl.Images.body.gif")) + ")";
                else
                    panel.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.BackImageUrl) + ")";
                panel.Style["background-color"] = System.Drawing.ColorTranslator.ToHtml(this._Master.BackColor);
                //
                #region BackgroundHeadControl
                Table tableHead = new Table();
                tableHead.CellPadding = 0;
                tableHead.CellSpacing = 0;
                tableHead.BorderWidth = Unit.Pixel(0);
                tableHead.Width = _Master.Width;
                tableHead.Height = _Master.HeadHeight;
                tableHead.Style["table-layout"] = "fixed";
                tableHead.Style["background-repeat"] = "repeat-x";
                if (string.IsNullOrEmpty(_Master.HeadBackImage))
                    tableHead.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.bg.gif")) + ")";
                else
                    tableHead.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadBackImage) + ")";
                panel.Controls.Add(tableHead);
                TableRow rowHead = new TableRow();
                rowHead.Height = _Master.HeadHeight;
                tableHead.Rows.Add(rowHead);
                //
                TableCell LogoCell = new TableCell();
                LogoCell.Height = _Master.HeadHeight;
                LogoCell.Width = _Master.HeadLogoCellWidth;
                LogoCell.Style["overflow"] = "hidden";
                LogoCell.Style["background-repeat"] = "no-repeat";
                this._Master.HeadLogoCell.Style["text-align"] = "left";
                if (string.IsNullOrEmpty(_Master.HeadLogoBackImage))
                    LogoCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.logobg.gif")) + ")";
                else
                    LogoCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadLogoBackImage) + ")";
                rowHead.Cells.Add(LogoCell);
                foreach (Control item in _Master.HeadLogoCell.Controls)
                {
                    LogoCell.Controls.Add(item);
                }
                //
                List<TableCell> cells = new List<TableCell>();
                foreach (TableCell cell in _Master.HeadItemCells)
                {
                    TableCell cellItem = new TableCell();
                    cellItem.Height = _Master.HeadHeight;
                    cellItem.Width = _Master.HeadItemWidth;
                    cellItem.Style["text-align"] = "left";
                    cellItem.Style["overflow"] = "hidden";
                    cellItem.Style["background-repeat"] = "repeat-x";
                    cellItem.Style["background-position"] = "left top";
                    if (string.IsNullOrEmpty(_Master.HeadItemBackImage))
                        cellItem.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.itembg.gif")) + ")";
                    else
                        cellItem.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadItemBackImage) + ")";
                    rowHead.Cells.Add(cellItem);
                    cells.Add(cellItem);
                }
                //
                for (int i = 0; i < _Master.HeadItems.Count; i++)
                {
                    Panel cellPanel = new Panel();
                    cellPanel.Height = _Master.HeadHeight;
                    cellPanel.Width = _Master.HeadItemWidth;
                    cellPanel.Style["text-align"] = "center";
                    cellPanel.Style["overflow"] = "hidden";
                    cellPanel.Style["background-repeat"] = "no-repeat";
                    cellPanel.Style["background-position"] = "left top";
                    if (string.IsNullOrEmpty(_Master.HeadSecludeBackImage))
                        cellPanel.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.seclude.gif")) + ")";
                    else
                        cellPanel.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadSecludeBackImage) + ")";
                    Panel TopPanel = new Panel();
                    TopPanel.Height = _Master.HeadItemPaddingTop;
                    cellPanel.Controls.Add(TopPanel);
                    //
                    LinkButton linkButton = new LinkButton();
                    linkButton.Text = _Master.HeadItems[i].Text;
                    linkButton.Font.CopyFrom(_Master.HeadItems[i].Font);
                    linkButton.ForeColor = _Master.HeadItems[i].ForeColor;
                    linkButton.ToolTip = _Master.HeadItems[i].ToolTip;
                    linkButton.PostBackUrl = _Master.HeadItems[i].PostBackUrl;
                    cellPanel.Controls.Add(linkButton);
                    cells[i].Controls.Add(cellPanel);
                }
                //
                TableCell LogoutCell = new TableCell();
                LogoutCell.Height = _Master.HeadHeight;
                LogoutCell.Style["width"] = "auto";
                //LogoutCell.Style["word-wrap"] = "keep-all";
                LogoutCell.Style["background-repeat"] = "no-repeat";
                LogoutCell.Style["background-position"] = "left top";
                LogoutCell.Style["vertical-align"] = "middle";
                LogoutCell.Style["text-align"] = "right";
                LogoutCell.Style["padding-right"] = "8px";
                LogoutCell.Style["padding-left"] = "8px";
                LogoutCell.Style["overflow"] = "hidden";
                if (string.IsNullOrEmpty(_Master.HeadSecludeBackImage))
                    LogoutCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.seclude.gif")) + ")";
                else
                    LogoutCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadSecludeBackImage) + ")";
                //
                foreach (Control item in _Master.HeadLogoutCell.Controls)
                {
                    LogoutCell.Controls.Add(item);
                }
                //
                foreach (Control item in LogoutCell.Controls)
                {
                    if (item is ImageButton && ((ImageButton)item).CommandName == "HeadLogout")
                    {
                        if (string.IsNullOrEmpty(this._Master.HeadLogoutImageUrl))
                        {
                            ((ImageButton)item).ImageUrl = this._Master.GetWebResourceUrl("BackgroundHeadControl.Images." + l + ".logout.gif");
                        }
                        else
                        {
                            ((ImageButton)item).ImageUrl = this._Master.HeadLogoutImageUrl;
                        }
                        break;
                    }
                }
                rowHead.Cells.Add(LogoutCell);
                panel.Controls.Add(tableHead);
                /*
                _Master.HeadTable.CellPadding = 0;
                _Master.HeadTable.CellSpacing = 0;
                _Master.HeadTable.BorderWidth = 0;
                //_Master.HeadTable.BackColor = _Master.HeadBackColor;
                //_Master.HeadTable.BorderColor = _Master.HeadBorderColor;
                //_Master.HeadTable.BorderStyle = _Master.HeadBorderStyle;
                //_Master.HeadTable.BorderWidth = _Master.HeadBorderWidth;
                _Master.HeadTable.Width = _Master.Width;
                _Master.HeadTable.Height = _Master.HeadHeight;
                this._Master.HeadTable.Style["table-layout"] = "fixed";
                this._Master.HeadTable.Style["background-repeat"] = "repeat-x";
                if (string.IsNullOrEmpty(_Master.HeadBackImage))
                    this._Master.HeadTable.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.bg.gif")) + ")";
                else
                    this._Master.HeadTable.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadBackImage) + ")";
                //
                _Master.HeadRow.Height = _Master.HeadHeight;
                //
                this._Master.HeadLogoCell.Height = _Master.HeadHeight;
                this._Master.HeadLogoCell.Width = _Master.HeadLogoCellWidth;//Unit.Pixel(188);
                this._Master.HeadLogoCell.Style["overflow"] = "hidden";
                this._Master.HeadLogoCell.Style["background-repeat"] = "no-repeat";
                this._Master.HeadLogoCell.Style["text-align"] = "_left";
                if (string.IsNullOrEmpty(_Master.HeadLogoBackImage))
                    this._Master.HeadLogoCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.logobg.gif")) + ")";
                else
                    this._Master.HeadLogoCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadLogoBackImage) + ")";
                //
                foreach (TableCell cell in _Master.HeadItemCells)
                {
                    cell.Height = _Master.HeadHeight;
                    cell.Width = _Master.HeadItemWidth;
                    cell.Style["text-align"] = "_left";
                    cell.Style["overflow"] = "hidden";
                    cell.Style["background-repeat"] = "repeat-x";
                    cell.Style["background-position"] = "left top";
                    if (string.IsNullOrEmpty(_Master.HeadItemBackImage))
                        cell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.itembg.gif")) + ")";
                    else
                        cell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadItemBackImage) + ")";
                }
                foreach (HeadItem item in _Master.HeadItems)
                {
                    item.LinkButton.Text = item.Text;
                    item.LinkButton.Font.CopyFrom(item.Font);
                    item.LinkButton.ForeColor = item.ForeColor;
                    item.LinkButton.ToolTip = item.ToolTip;
                    item.LinkButton.PostBackUrl = item.PostBackUrl;
                    item.Height = _Master.HeadHeight;
                    item.Width = _Master.HeadItemWidth;
                    item.Style["text-align"] = "center";
                    item.Style["overflow"] = "hidden";
                    item.Style["background-repeat"] = "no-repeat";
                    item.Style["background-position"] = "left top";
                    if (string.IsNullOrEmpty(_Master.HeadSecludeBackImage))
                        item.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.seclude.gif")) + ")";
                    else
                        item.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadSecludeBackImage) + ")";
                    //
                    item.TopPanel.Height = _Master.HeadItemPaddingTop;
                    //
                }
                //
                this._Master.HeadLogoutCell.Height = _Master.HeadHeight;
                this._Master.HeadLogoutCell.Style["width"] = "auto";
                //this._Master.LogoutCell.Style["word-wrap"] = "keep-all";
                this._Master.HeadLogoutCell.Style["background-repeat"] = "no-repeat";
                this._Master.HeadLogoutCell.Style["background-position"] = "left top";
                this._Master.HeadLogoutCell.Style["vertical-align"] = "middle";
                this._Master.HeadLogoutCell.Style["text-align"] = "_right";
                this._Master.HeadLogoutCell.Style["padding-right"] = "8px";
                this._Master.HeadLogoutCell.Style["padding-left"] = "8px";
                this._Master.HeadLogoutCell.Style["overflow"] = "hidden";
                if (string.IsNullOrEmpty(_Master.HeadSecludeBackImage))
                    this._Master.HeadLogoutCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundHeadControl.Images.seclude.gif")) + ")";
                else
                    this._Master.HeadLogoutCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.HeadSecludeBackImage) + ")";
                foreach (Control item in this._Master.HeadLogoutCell.Controls)
                {
                    if (item is ImageButton && ((ImageButton)item).CommandName == "HeadLogout")
                    {
                        if (string.IsNullOrEmpty(this._Master.HeadLogoutImageUrl))
                        {
                            ((ImageButton)item).ImageUrl = this._Master.GetWebResourceUrl("BackgroundHeadControl.Images." + l + ".logout.gif");
                        }
                        else
                        {
                            ((ImageButton)item).ImageUrl = this._Master.HeadLogoutImageUrl;
                        }
                        break;
                    }
                }
                */
                #endregion
                #region Center
                #region BackgroundCenterHeadControl
                Table tableCenterHead = new Table();
                tableCenterHead.CellPadding = 0;
                tableCenterHead.CellSpacing = 0;
                tableCenterHead.BorderWidth = Unit.Pixel(0);
                tableCenterHead.Height = _Master.CenterHeadHeight;
                if (this._Master.CenterWidth.IsEmpty)
                    tableCenterHead.Width = _Master.Width;
                else
                    tableCenterHead.Width = _Master.CenterWidth;
                tableCenterHead.Style["table-layout"] = "fixed";
                tableCenterHead.Style["overflow"] = "hidden";
                panel.Controls.Add(tableCenterHead);
                TableRow row = new TableRow();
                tableCenterHead.Rows.Add(row);
                /*
                TableCell MenuCell = new TableCell();
                MenuCell.Height = _Master.CenterHeadHeight;
                MenuCell.Width = _Master.CenterHeadMenuCellWidth;
                MenuCell.Style["overflow"] = "hidden";
                MenuCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadMenuCellBackImage))
                    MenuCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Menu.gif")) + ")";
                else
                    MenuCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadMenuCellBackImage) + ")";
                row.Cells.Add(MenuCell);
                foreach (Control item in _Master.CenterHeadMenuCell.Controls)
                {
                    MenuCell.Controls.Add(item);
                }
                 */ 
                //
                TableCell LeftCell = new TableCell();
                LeftCell.Height = _Master.Height;
                LeftCell.Width = _Master.CenterHeadLeftCellWidth;
                LeftCell.Style["overflow"] = "hidden";
                LeftCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadLeftCellBackImage))
                    LeftCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Left.gif")) + ")";
                else
                    LeftCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadLeftCellBackImage) + ")";
                row.Cells.Add(LeftCell);
                foreach (Control item in _Master.CenterHeadLeftCell.Controls)
                {
                    LeftCell.Controls.Add(item);
                }
                //
                TableCell CenterCell = new TableCell();
                CenterCell.Height = _Master.Height;
                if (_Master.CenterHeadCenterCellWidth.IsEmpty)
                    CenterCell.Style["width"] = "auto";
                else
                    CenterCell.Width = _Master.CenterHeadCenterCellWidth;
                CenterCell.Style["overflow"] = "hidden";
                CenterCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadCenterCellBackImage))
                    CenterCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Center.gif")) + ")";
                else
                    CenterCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadCenterCellBackImage) + ")";
                row.Cells.Add(CenterCell);
                foreach (Control item in _Master.CenterHeadCenterCell.Controls)
                {
                    CenterCell.Controls.Add(item);
                }
                //
                TableCell RightCell = new TableCell();
                RightCell.Height = _Master.Height;
                RightCell.Width = _Master.CenterHeadRightCellWidth;
                RightCell.Style["overflow"] = "hidden";
                RightCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadRightCellBackImage))
                    RightCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Right.gif")) + ")";
                else
                    RightCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadRightCellBackImage) + ")";
                row.Cells.Add(RightCell);
                /*
                _Master.CenterHeadTable.CellPadding = 0;
                _Master.CenterHeadTable.CellSpacing = 0;
                //_Master.CenterHeadTable.BackColor = _Master.BackColor;
                //_Master.CenterHeadTable.BorderColor = _Master.BorderColor;
                //_Master.CenterHeadTable.BorderStyle = _Master.BorderStyle;
                //_Master.CenterHeadTable.BorderWidth = _Master.BorderWidth;
                if (this._Master.CenterWidth.IsEmpty)
                    _Master.CenterHeadTable.Width = _Master.Width;
                else
                    _Master.CenterHeadTable.Width = _Master.CenterWidth;
                _Master.CenterHeadTable.Height = _Master.CenterHeadHeight;
                _Master.CenterHeadTable.Style["table-layout"] = "fixed";
                _Master.CenterHeadTable.Style["overflow"] = "hidden";
                //
                _Master.CenterHeadMenuCell.Height = _Master.CenterHeadHeight;
                _Master.CenterHeadMenuCell.Width = _Master.CenterHeadMenuCellWidth;// Unit.Pixel(150);
                _Master.CenterHeadMenuCell.Style["overflow"] = "hidden";
                _Master.CenterHeadMenuCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadMenuCellBackImage))
                    this._Master.CenterHeadMenuCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Menu.gif")) + ")";
                else
                    this._Master.CenterHeadMenuCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadMenuCellBackImage) + ")";
                //
                _Master.CenterHeadLeftCell.Height = _Master.CenterHeadHeight;
                _Master.CenterHeadLeftCell.Width = _Master.CenterHeadLeftCellWidth;
                _Master.CenterHeadLeftCell.Style["overflow"] = "hidden";
                _Master.CenterHeadLeftCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadLeftCellBackImage))
                    this._Master.CenterHeadLeftCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Left.gif")) + ")";
                else
                    this._Master.CenterHeadLeftCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadLeftCellBackImage) + ")";
                //
                _Master.CenterHeadCenterCell.Height = _Master.CenterHeadHeight;
                if (_Master.CenterHeadCenterCellWidth.IsEmpty)
                    _Master.CenterHeadCenterCell.Style["width"] = "auto";
                else
                    _Master.CenterHeadCenterCell.Width = _Master.CenterHeadCenterCellWidth;
                _Master.CenterHeadCenterCell.Style["overflow"] = "hidden";
                _Master.CenterHeadCenterCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadCenterCellBackImage))
                    this._Master.CenterHeadCenterCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Center.gif")) + ")";
                else
                    this._Master.CenterHeadCenterCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadCenterCellBackImage) + ")";
                //
                _Master.CenterHeadRightCell.Height = _Master.CenterHeadHeight;
                _Master.CenterHeadRightCell.Width = _Master.CenterHeadRightCellWidth;
                _Master.CenterHeadRightCell.Style["overflow"] = "hidden";
                _Master.CenterHeadRightCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(_Master.CenterHeadRightCellBackImage))
                    this._Master.CenterHeadRightCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.GetWebResourceUrl("BackgroundCenterHeadControl.Images.Right.gif")) + ")";
                else
                    this._Master.CenterHeadRightCell.Style["background-image"] = "url(" + _Master.ResolveClientUrl(_Master.CenterHeadRightCellBackImage) + ")";
                */
                #endregion
                #region Center
                #region Center
                Table Center = new Table();
                if (!this._Master.CenterWidth.IsEmpty)
                    Center.Width = this._Master.CenterWidth;
                Center.CellPadding = 0;
                Center.CellSpacing = 0;
                Center.BorderWidth = Unit.Pixel(0);
                panel.Controls.Add(Center);
                TableRow CenterRow = new TableRow();
                Center.Rows.Add(CenterRow);
                TableCell CenterLeft = new TableCell();
                CenterRow.Cells.Add(CenterLeft);
                TableCell BackgroundCenterRightControl = new TableCell();
                CenterRow.Cells.Add(BackgroundCenterRightControl);
                Panel CenterRightContainer = new Panel();
                BackgroundCenterRightControl.Controls.Add(CenterRightContainer);
                /*
                if (!this._Master.CenterWidth.IsEmpty)
                    this._Master.Center.Width = this._Master.CenterWidth;
                this._Master.Center.CellPadding = 0;
                this._Master.Center.CellSpacing = 0;
                this._Master.Center.BorderWidth = 0;
                //this._Master.Center.Style["overflow"] = "hidden";
                //this._Master.Center.Style["height"] = "auto";
                //this._Master.CenterLeft.Width = Unit.Pixel((int)(this._Master.CenterLeftWidth.Value + this._Master.CenterRightWidth.Value));
                */
                #endregion
                #region CenterLeft
                CenterLeft.Width = this._Master.CenterLeftWidth;
                //CenterLeft.Style["background-color"] = "#ffffff";
                CenterLeft.Style["position"] = "0px";
                CenterLeft.Style["text-align"] = "left";
                CenterLeft.Style["vertical-align"] = "top";
                #region Menu
                //this._Master.BackgroundCenterLeftMenuControl.Style["float"] = "_left";
                if (this._Master.CenterLeftMenuTitles.Count > 0)
                {
                    Panel BackgroundCenterLeftMenuControl = new Panel();
                    CenterLeft.Controls.Add(BackgroundCenterLeftMenuControl);
                    BackgroundCenterLeftMenuControl.Style["overflow"] = "hidden";
                    BackgroundCenterLeftMenuControl.Width = this._Master.CenterLeftWidth;
                    //BackgroundCenterLeftMenuControl.Height = this._CenterLeftMenu.Height;
                    foreach (BackgroundCenterLeftMenuTitleControl item in this._Master.CenterLeftMenuTitles)
                    {
                        //
                        Panel title = new Panel();
                        BackgroundCenterLeftMenuControl.Controls.Add(title);
                        title.Style["overflow"] = "hidden";
                        title.Width = this._Master.CenterLeftWidth;
                        //
                        Panel titleContainer = new Panel();
                        titleContainer.Style["background-position"] = "left top";
                        titleContainer.Width = this._Master.CenterLeftWidth;
                        titleContainer.Height = this._Master.CenterLeftMenuTitleHeight;
                        if (string.IsNullOrEmpty(this._Master.CenterLeftMenuTitleBackImage))
                            titleContainer.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.TitleBg.gif")) + ")";
                        else
                            titleContainer.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterLeftMenuTitleBackImage) + ")";
                        title.Controls.Add(titleContainer);
                        //
                        Panel iconContainer = new Panel();
                        iconContainer.Style["float"] = "left";
                        iconContainer.Style["padding-top"] = "5px";
                        iconContainer.Style["padding-left"] = "1px";
                        iconContainer.Style["font-size"] = "0px";
                        iconContainer.Style["overflow"] = "hidden";
                        title.Controls.Add(iconContainer);
                        System.Web.UI.WebControls.Image icon = new System.Web.UI.WebControls.Image();

                        iconContainer.Controls.Add(icon);
                        titleContainer.Controls.Add(iconContainer);
                        //
                        Panel buttonContainer = new Panel();
                        buttonContainer.Style["float"] = "left";
                        buttonContainer.Style["padding-top"] = "5px";
                        buttonContainer.Style["padding-left"] = "0px";
                        buttonContainer.Style["font-size"] = "0px";
                        buttonContainer.Style["overflow"] = "hidden";
                        //
                        LinkButton titleButton = new LinkButton();
                        titleButton.Text = item.Text;
                        titleButton.ForeColor = item.ForeColor;
                        titleButton.Font.CopyFrom(item.Font);
                        titleButton.CommandName = item.CommandName;
                        titleButton.CommandArgument = item.CommandArgument;
                        buttonContainer.Controls.Add(titleButton);
                        //
                        titleContainer.Controls.Add(buttonContainer);
                        //
                        Panel contentContainer = new Panel();
                        if (item.IsExpanded)
                        {
                            if (this._Master.CenterLeftMenuExpandedIcon == string.Empty)
                                icon.ImageUrl = this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.Expanded.gif"));
                            else
                                icon.ImageUrl = this._Master.ResolveClientUrl(this._Master.CenterLeftMenuExpandedIcon);
                        }
                        else
                        {
                            if (this._Master.CenterLeftMenuCollapseIcon == string.Empty)
                                icon.ImageUrl = this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.Collapse.gif"));
                            else
                                icon.ImageUrl = this._Master.ResolveClientUrl(this._Master.CenterLeftMenuCollapseIcon);
                            //
                            contentContainer.Style["display"] = "none";
                        }
                        //

                        if (!this._Master.CenterLeftMenuTitleTextWidth.IsEmpty)
                        {
                            buttonContainer.Style["white-space"] = "nowrap";
                            buttonContainer.Style["text-overflow"] = "ellipsis";
                            buttonContainer.Style["-o-text-overflow"] = "ellipsis";
                            buttonContainer.Style["width"] = this._Master.CenterLeftMenuTitleTextWidth.ToString();
                        }
                        //
                        contentContainer.Width = item.Width;
                        title.Controls.Add(contentContainer);
                        foreach (BackgroundCenterLeftMenuButtonControl citem in item.Buttons)
                        {
                            Panel buttons = new Panel();
                            buttons.Style["overflow"] = "hidden";
                            buttons.Style["background-position"] = "left top";
                            buttons.Style["white-space"] = "nowrap";
                            buttons.Style["text-overflow"] = "ellipsis";
                            buttons.Height = this._Master.CenterLeftMenuButtonHeight;
                            buttons.Width = this._Master.CenterLeftWidth;
                            if (citem.IsSelected)
                                if (string.IsNullOrEmpty(this._Master.CenterLeftMenuSelectedButtonBackImage))
                                    buttons.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.SelectedButtonBg.gif")) + ")";
                                else
                                    buttons.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterLeftMenuSelectedButtonBackImage) + ")";
                            else
                                if (string.IsNullOrEmpty(this._Master.CenterLeftMenuButtonBackImage))
                                    buttons.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.ButtonBg.gif")) + ")";
                                else
                                    buttons.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterLeftMenuButtonBackImage) + ")";
                            contentContainer.Controls.Add(buttons);
                            //
                            Panel buttonsContainer = new Panel();
                            buttonsContainer.Height = this._Master.CenterLeftMenuButtonHeight;
                            buttonsContainer.Width = this._Master.CenterLeftWidth;
                            buttonsContainer.Style["overflow"] = "hidden";
                            buttonsContainer.Style["font-size"] = "0px";
                            buttonsContainer.Style["padding-top"] = "5px";
                            buttonsContainer.Style["padding-left"] = "4px";
                            buttons.Controls.Add(buttonsContainer);
                            //
                            LinkButton kinkButtons = new LinkButton();
                            kinkButtons.Text = citem.Text;
                            kinkButtons.ForeColor = citem.ForeColor;
                            kinkButtons.Font.CopyFrom(citem.Font);
                            buttonsContainer.Controls.Add(kinkButtons);
                        }
                    }
                    //
                    Panel end = new Panel();
                    if (this._Master.CenterLeftMenuShowEnd)
                    {
                        end.Visible = true;
                        end.Style["background-position"] = "left top";
                        end.Width = this._Master.CenterLeftWidth;
                        end.Height = this._Master.CenterLeftMenuEndHeight;
                        if (string.IsNullOrEmpty(this._Master.CenterLeftMenuTitleBackImage))
                            end.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.EndBg.gif")) + ")";
                        else
                            end.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterLeftMenuTitleBackImage) + ")";
                    }
                    else
                    {
                        end.Visible = false;
                    }
                    BackgroundCenterLeftMenuControl.Controls.Add(end);
                }
                else
                {
                    System.Resources.ResourceManager rm = new System.Resources.ResourceManager(typeof(Properties.Resources));
                    string s = "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.Height.ToString() + " ;background-color: " + (this._Master.BackColor.IsEmpty ? "#FFFFFF" : System.Drawing.ColorTranslator.ToHtml(this._Master.BackColor)) + ";'>" +
                           "<div style='overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuTitleHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuTitleBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.TitleBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuTitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._Master.CenterLeftMenuCollapseIcon == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.Collapse.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuCollapseIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                        //
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuTitleHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuTitleBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.TitleBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuTitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._Master.CenterLeftMenuCollapseIcon == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.Collapse.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuCollapseIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                        //
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuTitleHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuTitleBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.TitleBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuTitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._Master.CenterLeftMenuExpandedIcon == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.Expanded.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuExpandedIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                        //演示按钮
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuButtonBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.ButtonBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoButton") +
                           "</div>" +
                           "</div>" +
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuButtonBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.ButtonBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoButton") +
                           "</div>" +
                           "</div>" +
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuSelectedButtonBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.SelectedButtonBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuSelectedButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoSelectedButton") +
                           "</div>" +
                           "</div>" +
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuButtonBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.ButtonBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuButtonBackImage)) + ");'>" +
                           "<div style='font-size: 12px; font-weight: bold;padding-top: 7px; padding-left: 4px; overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuButtonHeight.ToString() + ";'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoButton") +
                           "</div>" +
                           "</div>" +
                        //
                           "<div style='white-space:nowrap;text-overflow:ellipsis;overflow:hidden ;width:" + this._Master.Width.ToString() + " ;height:" + this._Master.CenterLeftMenuTitleHeight.ToString() + "; background-image:url(" + (this._Master.CenterLeftMenuTitleBackImage == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.TitleBg.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuTitleBackImage)) + ");'>" +
                           "<div style='float: left;padding-top: 5px; padding-left: 1px;'>" +
                           "<img src='" + (this._Master.CenterLeftMenuCollapseIcon == string.Empty ? this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterLeftMenuControl.Images.Collapse.gif")) : this._Master.ResolveClientUrl(this._Master.CenterLeftMenuCollapseIcon)) + "' />" +
                           "</div>" +
                           "<div style='float: left;font-size: 14px; font-weight: bold;padding-top: 8px; padding-left: 0px;'>" +
                           rm.GetString("Manage_CenterLeftMenu_Designer_DemoTitle") +
                           "</div>" +
                           "</div>" +
                           "</div>";
                    //CenterLeft.Controls.Clear();
                    CenterLeft.Controls.Add(new LiteralControl(s));
                }
                #endregion
                #endregion
                #region BackgroundCenterRightControl
                if (!this._Master.CenterWidth.IsEmpty)
                {
                    if (this._Master.CenterWidth.Type == UnitType.Percentage)
                    {
                        BackgroundCenterRightControl.Width = this._Master.CenterWidth;
                    }
                    else
                    {
                        BackgroundCenterRightControl.Width = Unit.Pixel((int)(this._Master.CenterWidth.Value - this._Master.CenterLeftWidth.Value));
                    }
                }
                BackgroundCenterRightControl.Style["background-color"] = "#ffffff";
                BackgroundCenterRightControl.Style["padding-bottom"] = this._Master.CenterRightContainerPaddingBottom.ToString();
                BackgroundCenterRightControl.Style["padding-left"] = this._Master.CenterRightContainerPaddingLeft.ToString();
                BackgroundCenterRightControl.Style["padding-right"] = this._Master.CenterRightContainerPaddingRight.ToString();
                BackgroundCenterRightControl.Style["padding-top"] = this._Master.CenterRightContainerPaddingTop.ToString();
                //
                BackgroundCenterRightControl.Style["background-position"] = "right top";
                BackgroundCenterRightControl.Style["background-repeat"] = "repeat-y";
                if (string.IsNullOrEmpty(this._Master.CenterRightBackImage))
                    BackgroundCenterRightControl.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterRightControl.Images.bg.gif")) + ")";
                else
                    BackgroundCenterRightControl.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterRightBackImage) + ")";
                BackgroundCenterRightControl.Style["overflow"] = "hidden";
                //
                #region CenterRightContainer
                CenterRightContainer.Style["overflow"] = "hidden";
                CenterRightContainer.Style["text-align"] = "center";
                CenterRightContainer.Style["font-size"] = "12px";
                CenterRightContainer.Controls.Clear();
                string text = "Ascx Container";
                text += "<br />";
                text += "需要使用FileUpload上传控件必须在配置文件添加";
                text += "<br />";
                text += "&lt;System.Web&gt;<br />&lt;httpModules&gt;<br />&lt;add name=&quot;AjaxFileUploadModule&quot; type=&quot;GSC.WebControls.AjaxFileUploadModule, GSC.WebControls.AjaxFileUploadHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e6d560ce7567553b&quot;&frasl;&gt;<br />&lt;&frasl;httpModules&gt;<br />&lt;&frasl;System.Web&gt;";
                text += "<br />";
                text += "&lt;System.WebServer&gt;<br />&lt;Modules&gt;<br />&lt;add name=&quot;AjaxFileUploadModule&quot; type=&quot;GSC.WebControls.AjaxFileUploadModule, GSC.WebControls.AjaxFileUploadHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e6d560ce7567553b&quot;&frasl;&gt;<br />&lt;&frasl;Modules&gt;<br />&lt;&frasl;System.WebServer&gt;"; 
                CenterRightContainer.Controls.Add(new LiteralControl(text));
                #endregion
                #endregion
                #region BackgroundCenterEndControl
                Table CenterEndTable = new Table();
                panel.Controls.Add(CenterEndTable);
                TableRow CenterEndTableRow = new TableRow();
                CenterEndTable.Rows.Add(CenterEndTableRow);
                CenterEndTable.CellPadding = 0;
                CenterEndTable.CellSpacing = 0;
                CenterEndTable.BorderWidth = Unit.Pixel(0);
                if (this._Master.CenterWidth.IsEmpty)
                    CenterEndTable.Width = this._Master.Width;
                else
                    CenterEndTable.Width = this._Master.CenterWidth;
                CenterEndTable.Height = this._Master.CenterEndHeight;
                CenterEndTable.Style["table-layout"] = "fixed";
                CenterEndTable.Style["overflow"] = "hidden";
                /*
                TableCell CenterEndMenuCell = new TableCell();
                CenterEndTableRow.Cells.Add(CenterEndMenuCell);
                CenterEndMenuCell.Height = this._Master.Height;
                CenterEndMenuCell.Width = this._Master.CenterEndMenuCellWidth;
                CenterEndMenuCell.Style["overflow"] = "hidden";
                CenterEndMenuCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(this._Master.CenterEndMenuCellBackImage))
                    CenterEndMenuCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterEndControl.Images.Menu.gif")) + ")";
                else
                    CenterEndMenuCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterEndMenuCellBackImage) + ")";
                */
                TableCell CenterEndLeftCell = new TableCell();
                CenterEndTableRow.Cells.Add(CenterEndLeftCell);
                CenterEndLeftCell.Height = this._Master.Height;
                CenterEndLeftCell.Width = this._Master.CenterEndLeftCellWidth;
                CenterEndLeftCell.Style["overflow"] = "hidden";
                CenterEndLeftCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(this._Master.CenterEndLeftCellBackImage))
                    CenterEndLeftCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterEndControl.Images.Left.gif")) + ")";
                else
                    CenterEndLeftCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterEndLeftCellBackImage) + ")";
                //
                TableCell CenterEndCenterCell = new TableCell();
                CenterEndTableRow.Cells.Add(CenterEndCenterCell);
                CenterEndCenterCell.Height = this._Master.Height;
                if (this._Master.CenterEndCenterCellWidth.IsEmpty)
                    CenterEndCenterCell.Style["width"] = "auto";
                else
                    CenterEndCenterCell.Width = this._Master.CenterEndCenterCellWidth;
                CenterEndCenterCell.Style["overflow"] = "hidden";
                CenterEndCenterCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(this._Master.CenterEndCenterCellBackImage))
                    CenterEndCenterCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterEndControl.Images.Center.gif")) + ")";
                else
                    CenterEndCenterCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterEndCenterCellBackImage) + ")";
                //
                TableCell CenterEndRightCell = new TableCell();
                CenterEndTableRow.Cells.Add(CenterEndRightCell);
                CenterEndRightCell.Height = this._Master.Height;
                CenterEndRightCell.Width = this._Master.CenterEndRightCellWidth;
                CenterEndRightCell.Style["overflow"] = "hidden";
                CenterEndRightCell.Style["background-position"] = "left top";
                if (string.IsNullOrEmpty(this._Master.CenterEndRightCellBackImage))
                    CenterEndRightCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCenterEndControl.Images.Right.gif")) + ")";
                else
                    CenterEndRightCell.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CenterEndRightCellBackImage) + ")";
                #endregion
                #endregion
                #endregion
                #region BackgroundCopyrightControl
                Panel BackgroundCopyrightControl = new Panel();
                panel.Controls.Add(BackgroundCopyrightControl);
                if (this._Master.CopyrightWidth.IsEmpty)
                    BackgroundCopyrightControl.Width = this._Master.Width;
                else
                    BackgroundCopyrightControl.Width = this._Master.CopyrightWidth;
                BackgroundCopyrightControl.Height = this._Master.CopyrightHeight;
                BackgroundCopyrightControl.Style["overflow"] = "hidden";
                BackgroundCopyrightControl.Style["background-position"] = "center";
                BackgroundCopyrightControl.Style["background-repeat"] = "no-repeat";
                if (string.IsNullOrEmpty(this._Master.CopyrightBackImage))
                    BackgroundCopyrightControl.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.GetWebResourceUrl("BackgroundCopyrightControl.Images.BackgroundCopyrightControl.gif")) + ")";
                else
                    BackgroundCopyrightControl.Style["background-image"] = "url(" + this._Master.ResolveClientUrl(this._Master.CopyrightBackImage) + ")";
                foreach (Control item in _Master.CopyrightTable.Controls)
                {
                    BackgroundCopyrightControl.Controls.Add(item);
                }
                #endregion
                //
                StringWriter sw = new StringWriter();
                HtmlTextWriter hw = new HtmlTextWriter(sw);
                panel.RenderControl(hw);
                return sw.ToString();
            }
            catch (Exception ex)
            {
                return ex.ToString();
            }
        }
    }
}